home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / SBIN / PPP-OFF < prev    next >
Text File  |  1999-09-17  |  2KB  |  69 lines

  1. #!/bin/bash
  2. #
  3. # This is the standard ppp-off script that comes with ppp-2.?.?, it's
  4. # been expanded to include the -d option for pppsetup. (1-17-98)
  5. #
  6. ######################################################################
  7. #
  8. # Determine the device to be terminated.
  9. #
  10. if [ "$1" = "" ]; then
  11.     DEVICE=ppp0
  12. elif [ ! "$1" = "-d" ]; then
  13.     DEVICE=$1    
  14. elif [ "$1" = "-d" ]; then
  15.     DEVICE=ppp0    
  16. elif [ ! "$1" = "" ] && [ "$2" = "-d" ]; then
  17.     DEVICE=$1    
  18. fi
  19. ######################################################################
  20. #
  21. # This just checks if demand dialing is running, if so it
  22. # says Demand Dialing Stoped.
  23.  
  24. ps x 2>/dev/null > /tmp/grep.tmp
  25.  
  26. if grep 2>/dev/null "options.demand" /tmp/grep.tmp >/dev/null
  27. then
  28. rm -f /tmp/grep.tmp
  29. D="echo Demand Dialing Stoped."
  30. else
  31. rm -f /tmp/grep.tmp
  32. fi
  33.  
  34. #
  35. # If the ppp0 pid file is present then the program is running. Stop it.
  36. if [ -r /var/run/$DEVICE.pid ]; then
  37.         kill -INT `cat /var/run/$DEVICE.pid`
  38. #
  39. # If the kill did not work then there is no process running for this
  40. # pid. It may also mean that the lock file will be left. You may wish
  41. # to delete the lock file at the same time.
  42.         if [ ! "$?" = "0" ]; then
  43.             killall -INT pppd 2>/dev/null
  44.                 rm -f /var/run/$DEVICE.pid
  45.                 rm -f /var/lock/LCK*
  46.                 echo "ERROR: No pppd process running, removed stale pid file."
  47.                 exit 1
  48.         fi
  49. #
  50. # Success. Let pppd clean up its own junk.
  51.         echo "PPP link to [$DEVICE] terminated."
  52.         $D
  53.         if [ "$1" = "-d" ]; then
  54.     pppd file "/etc/ppp/options.demand" || exit 1
  55.     echo "Demand Dialing Started."
  56.     exit 0
  57.     elif [ "$2" = "-d" ]; then
  58.     pppd file "/etc/ppp/options.demand" || exit 1
  59.     echo "Demand Dialing Started."
  60.     exit 0
  61.     else
  62.     exit 0
  63. fi
  64. fi
  65. #
  66. # The ppp process is not running for ppp0
  67. echo "ERROR: PPP link is not active on: [$DEVICE]"
  68. exit 1
  69.